<!DOCTYPE html>
<html>
<head>
    <title>我的游记</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

</head>

<body>
    <div class="search-head">
        <div class="row nav-search">
            <div class="col">
                <a href="profiles.html">
                    <span><i class="fa fa-chevron-left"></i></span>
                </a>
            </div>
            <div class="col">
                <span>我的游记</span>
            </div>
            <div class="col"></div>
        </div>
    </div>

    <div class="container travels">
        <dl class="list" render-loop="list">
            <dd>
                <a href="editTravels.html" render-fun="handle" render-key="list.id">
                    <img render-src="list.coverUrl">
                    <h6 class="title" render-html="list.title"></h6>
                    <p>最近更新时间 <span render-html="list.lastUpdateTime"></span>
                        <span class="span-right">
                        <i class="fa fa-heart"></i><span>0</span>收藏
                        <i class="fa fa-thumbs-o-up"></i><span>0</span>点赞</span>
                    </p>
                </a>
            </dd>

        </dl>
    </div>

<script>

    var currentPage=1;
    var pages;
    var travles;

    $(function () {
        var user=getUser();
        //发送ajax请求，获取当前用户所有的游记
        $.get("/users/"+user.id+"/travels",{state:-2},function (data) {
            console.log(data);
            $(".travels").renderValues(data,{
                handle:function (ele,value) {
                    //渲染a标签
                    console.log(ele);
                    console.log(value);
                    ele.href="editTravels.html?id="+value;
                }
            });
            //总页数
            pages=data.pages;
            //存储数据下一页之前的数据
            travles=data.list;
        })


        //当前窗口绑定滚动事件
        $(window).scroll(function () {
            //判断当前是否滚动到底部
            if (isFull()) {
                if (currentPage < pages) {
                    $.get("/users/"+user.id+"/travels",{currentPage:++currentPage,state:-2},function (data) {
                        console.log(data);
                        $.merge(travles,data.list);
                        $(".travels").renderValues({list:travles},{
                            handle:function (ele,value) {
                                //渲染a标签
                                console.log(ele);
                                console.log(value);
                                ele.href="editTravels.html?id="+value;
                            }
                        });

                    })
                }else{
                    $(document).dialog({
                        type : 'notice',
                        infoText: "亲，没有数据了",
                        autoClose: 1500,
                        position: 'bottom'  // center: 居中; bottom: 底部
                    });
                }
            }
        })


    });
</script>

</body>
</html>
